app.controller('LocationALLCtrl', function ($scope, $stateParams, ajax) {
	/* global BMap */
	$scope.city = $stateParams.city;

	$scope.cityName = $stateParams.name;

	$scope.$on('han.map.init', function () {
		var map = $scope.map;
		map.enableScrollWheelZoom(); //缩放
		map.centerAndZoom($scope.cityName + "市");
		// 编写自定义函数,创建标注
		// function addMarker(point, titles) {
		// 	var marker = new BMap.Marker(point, { title: titles });
		// 	map.addOverlay(marker);
		// }
		for (var i = 0; i < $scope.pointArray.length; i++) {
			var lng = $scope.pointArray[i].point.longitude;
			var lat = $scope.pointArray[i].point.latitude;
			var point = new BMap.Point(lng, lat);
			var titles = $scope.pointArray[i].address;
			var marker = new BMap.Marker(point, { title: titles });
			map.addOverlay(marker);
		}
	});

	$scope.pointArray = [];

	$scope.reload = function () {
		ajax.call(new Req.GET({
			resource: 'location/rt/' + $scope.city + '/point'
		})).then(function (result) {
			$scope.pointArray = result.result;
			$scope.text = "当前城市为：" + $scope.cityName + "，共有" + $scope.pointArray.length + "个推荐点。";
		}, function () { });
	};
	$scope.reload();
});